﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using System.Data;
namespace DataAccess.User
{
    public class UserDAL
    {
        private SQLDataAccess db;
        public UserDAL ()
        {
            db = new SQLDataAccess();
        }
        public bool checkLogin(string email, string password)
        {


            DataTable tb = db.exeSelect("select * from [User] where Email='" + email + "' and Password='" + password + "'");
            if (tb != null&&tb.Rows.Count>0)
            {
                return true;
            }
            return false;
        }
        public FOModels.User.User seacrhUser(string email)
        {
            FOModels.User.User us=null;
            try
            {
                Fcom.IDLib.SaveMoneyID.AccountsynClient client = new Fcom.IDLib.SaveMoneyID.AccountsynClient();
                Fcom.IDLib.SaveMoneyID.FullUserInfo fullinfo = client.getUserInfo(email);
                us = new FOModels.User.User();
                us.DisplayName = fullinfo.Fullname;
                us.Email = fullinfo.Email;
                us.GroupID = fullinfo.GroupID;
                us.Status = fullinfo.Status;
                us.Username = fullinfo.Username;
              
            }
            catch
            {
                us = null;
            }
            return us;
        }

        public string[] RoleForUser(string email)
        {
            FOModels.User.User us = seacrhUser(email);
            string[] str = new string[1];
            str[0] = us.GroupID.ToString() ;
            return str;
        }
    }
}
